home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / bsMultiIndexForTarget.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.5 KB  |  89 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  June, 2000
  22. //
  23.  
  24. global proc int
  25. bsMultiIndexForTarget(string $bsn, int $wc)
  26. //
  27. //    Description:
  28. //        Return the multiIndex that corresponds to target $wc on $bsn.
  29. //
  30. {
  31.     string $sArr[] = `ls -sl`;
  32.     if (nodeType($bsn) != "blendShape") {
  33.         // find the blendShape node:
  34.         // $bsn may be either the blendShape node, or the transform
  35.         // above the base shape of the blendShape
  36.         //
  37.         string $isType[] = `ls -type transform $bsn`;
  38.         if (size($isType)) {
  39.             string $children[] = `pickWalk -d down $bsn`;
  40.             if (size($children)) {
  41.                 $bsn = $children[0];
  42.             }
  43.             select -r $sArr;
  44.         }
  45.         $isType = `listConnections -type blendShape $bsn`;
  46.         if (size($isType)) {
  47.             $bsn = $isType[0];
  48.         } else {
  49.             error("Must specify a blendShape node.");
  50.             return -1;
  51.         }
  52.     }
  53.  
  54.     // if final target index is being requested, search for the max target
  55.     //
  56.     int $maxTarget = 0;
  57.     int $searchForMax = (`blendShape -q -wc $bsn` == ($wc+1));
  58.     
  59.     string $allTargets[] = `listAttr -m ($bsn+".inputTarget")`;
  60.     string $targets[];
  61.     for ($t in $allTargets) {
  62.         // weed out the in-between targets
  63.         //
  64.         if ("" != `match "6000" $t` && "" != `match  "inputPointsTarget" $t` ) {
  65.             $targets[size($targets)] = $t;
  66.  
  67.             if ($searchForMax) {
  68.                 int $tmp = bsTargetIndex($t);
  69.                 if ($tmp > $maxTarget) {
  70.                     $maxTarget = $tmp;
  71.                 }
  72.             }
  73.         }
  74.     }
  75.     if (size($targets) <= $wc) {
  76.         return -1;
  77.     }
  78.  
  79.     int $targetIndex;
  80.     if ($searchForMax) {
  81.         $targetIndex = $maxTarget;
  82.     } else {
  83.         string $targetPlug = $targets[$wc];
  84.         $targetIndex = bsTargetIndex($targetPlug);
  85.     }
  86.     return $targetIndex;
  87. }
  88.  
  89.